import Types from '../../action/types.js'

const defaultState = {};
export default function onAction(state = defaultState, action) {
  switch (action.type) {
    case Types.MALL_REFRESH_SUCCESS:
      return {
        ...state,
        [action.storeName]: {
          ...state[action.storeName],
          items: action.items,
          isLoading: false,
        }
      };
    case Types.MALL_REFRESH:
      return {
        ...state,
        [action.storeName]: {
          ...state[action.storeName],
          isLoading: false,
        }
      }
    case Types.MALL_REFRESH_FAIL:
      return {
        ...state,
        [action.storeName]: {
          ...state[action.storeName],
          isLoading: false,
        }
      }
    default:
      return state;
  }
}